home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9975 < prev    next >
Encoding:
Text File  |  1996-08-05  |  967 b   |  30 lines

  1. Newsgroups: comp.lang.c
  2. Path: undergrad.math.uwaterloo.ca!crpalmer
  3. From: crpalmer@solo.uwaterloo.ca (Chris Palmer)
  4. Subject: #define "creating" strings ?
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <Do9tsI.H2t@undergrad.math.uwaterloo.ca>
  7. Date: Thu, 14 Mar 1996 18:53:06 GMT
  8. Nntp-Posting-Host: solo.uwaterloo.ca
  9. Organization: University of Waterloo
  10.  
  11. I have a problem that I would like to solve using a "feature" of the C
  12. preprocessor that until now I've never seen or heard of.  A book that we have
  13. here gives the example:
  14.  
  15. #define MAKESTRING(x) "x"
  16.  
  17. which does in fact produce strings that have the value of x substituted.
  18. [eg: MAKESTRING(foo) gets processed into "foo"].
  19.  
  20. I've verified this on a DEC Alpha (cc) and the GNU C compiler..
  21.  
  22. Is this in fact a supported behaviour that should be portable to most
  23. C compilers?
  24.  
  25. Cheers,
  26. Chris.
  27. -- 
  28. Mail: crpalmer@undergrad.uwaterloo.ca
  29. Homepage: http://www.undergrad.math.uwaterloo.ca/~crpalmer/
  30.